import instance from "@/utils/http.js"


export const getDetailApi = (id) => {
  return instance.get('/goods', {
    params: {
      id
    }
  })
}


export const getchHotGoodsAPI = ({ id, type, limit = 3 }) => {
  return instance.get(
    '/goods/hot', {
    params: {
      id,
      type,
      limit
    }
  })
}


// 加入购物车
export const insertCartAPI = ({ skuId, count }) => {
  return instance.post('/member/cart',
    {
      skuId,
      count
    })
}
// 获取最新的购物车列表
export const findNewCartListAPI = () => {
  return instance.get('/member/cart')
}


// 删除购物车
export const delCartAPI = (ids) => {
  console.log(ids)
  return instance({
    url: '/member/cart',
    method: 'DELETE',
    data: {
      ids
    }
  })
  // return instance.delete(
  //  '/member/cart',
  //   {
  //     ids:ids
  //   }
  // )
}

// 合并购物车

export const mergeCartAPI = (data) => {
  return instance({
    url: '/member/cart/merge',
    method: 'POST',
    data
  })
}


export const getCheckoutInfoAPI = () => {
  return instance({
    url:'/member/order/pre'
  })
}

// 创建订单
export const createOrderAPI = (data) => {
  return instance({
    url: '/member/order',
    method: 'POST',
    data
  })
}
